package com.etc.controller;

import java.io.IOException;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.etc.entity.AsBoard;
import com.etc.entity.AsUser;
import com.etc.service.IAsBoardService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 画报管理Controller
 * 
 * @author ruoyi
 * @date 2022-11-27
 */
@RestController
@RequestMapping("/board")
@Api()
public class AsBoardController
{
    @Autowired
    private IAsBoardService asBoardService;

    /**
     * 查询画报管理列表
     */

    @GetMapping("/list")
    public PageInfo<AsBoard> list(@RequestParam(value = "keywords" , required = false,defaultValue = "")String keywords, @RequestParam(value = "offset",defaultValue = "1",required = false) int page, @RequestParam(value = "limit",defaultValue = "10",required = false) int limit)
    {

        Page<AsBoard> list = asBoardService.selectAsBoardList(keywords,page,limit);
        PageInfo<AsBoard> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    /**
     * 导出画报管理列表
     */


//    @PostMapping("/export")
//    public void export(HttpServletResponse response, AsBoard asBoard) throws IOException {
//        List<AsBoard> list = asBoardService.selectAsBoardList(asBoard);
//        ExcelUtil<AsBoard> util = new ExcelUtil<AsBoard>(AsBoard.class);
//        util.exportExcel(response, list, "画报管理数据");
//    }

    /**
     * 获取画报管理详细信息
     */

    @GetMapping(value = "/{userid}")
    public List<AsBoard> getInfo(@PathVariable("userid") Long userid)
    {
        return asBoardService.selectAsBoardByUserId(userid);
    }

    @GetMapping(value = "board/{boardid}")
    public AsBoard getInfo2(@PathVariable("boardid") Long boardid)
    {
        return asBoardService.selectAsBoardByBoardId(boardid);
    }

    /**
     * 新增画报管理
     */


    @PostMapping
    public AsBoard add(@RequestBody AsBoard asBoard)
    {
        AsBoard asBoard1 = asBoardService.insertAsBoard(asBoard);
        return asBoard1;
    }

    /**
     * 修改画报管理
     */


    @PutMapping
    public AjaxResult edit(@RequestBody AsBoard asBoard)
    {
        return AjaxResult.success();
    }

    /**
     * 删除画报管理
     */


	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return AjaxResult.success();
    }
}
